package lexical;

public enum TokenKind {
    // 关键字
    KEYWORD_FALSE(0, "False", "KEYWORD_FALSE"),
    KEYWORD_NONE(1, "None", "KEYWORD_NONE"),
    KEYWORD_TRUE(2, "True", "KEYWORD_TRUE"),
    KEYWORD_AND(3, "and", "KEYWORD_AND"),
    KEYWORD_AS(4, "as", "KEYWORD_AS"),
    KEYWORD_ASSERT(5, "assert", "KEYWORD_ASSERT"),
    KEYWORD_BREAK(6, "break", "KEYWORD_BREAK"),
    KEYWORD_CLASS(7, "class", "KEYWORD_CLASS"),
    KEYWORD_CONTINUE(8, "continue", "KEYWORD_CONTINUE"),
    KEYWORD_DEF(9, "def", "KEYWORD_DEF"),
    KEYWORD_DEL(10, "del", "KEYWORD_DEL"),
    KEYWORD_ELIF(11, "elif", "KEYWORD_ELIF"),
    KEYWORD_ELSE(12, "else", "KEYWORD_ELSE"),
    KEYWORD_EXCEPT(13, "except", "KEYWORD_EXCEPT"),
    KEYWORD_FINALLY(14, "finally", "KEYWORD_FINALLY"),
    KEYWORD_FOR(15, "for", "KEYWORD_FOR"),
    KEYWORD_FROM(16, "from", "KEYWORD_FROM"),
    KEYWORD_GLOBAL(17, "global", "KEYWORD_GLOBAL"),
    KEYWORD_IF(18, "if", "KEYWORD_IF"),
    KEYWORD_IMPORT(19, "import", "KEYWORD_IMPORT"),
    KEYWORD_IN(20, "in", "KEYWORD_IN"),
    KEYWORD_IS(21, "is", "KEYWORD_IS"),
    KEYWORD_LAMBDA(22, "lambda", "KEYWORD_LAMBDA"),
    KEYWORD_NONLOCAL(23, "nonlocal", "KEYWORD_NONLOCAL"),
    KEYWORD_NOT(24, "not", "KEYWORD_NOT"),
    KEYWORD_OR(25, "or", "KEYWORD_OR"),
    KEYWORD_PASS(26, "pass", "KEYWORD_PASS"),
    KEYWORD_RAISE(27, "raise", "KEYWORD_RAISE"),
    KEYWORD_RETURN(28, "return", "KEYWORD_RETURN"),
    KEYWORD_TRY(29, "try", "KEYWORD_TRY"),
    KEYWORD_WHILE(30, "while", "KEYWORD_WHILE"),
    KEYWORD_WITH(31, "with", "KEYWORD_WITH"),

    // 常量
    CONSTANT_INT(32, "", "CONSTANT_INT"),
    CONSTANT_FLOAT(33, "", "CONSTANT_FLOAT"),
    CONSTANT_BOOL(34, "", "CONSTANT_BOOL"),
    CONSTANT_COMPLEX(35, "", "CONSTANT_COMPLEX"),
    CONSTANT_STR(36, "", "CONSTANT_STR"),

    // 标识符
    IDENTIFIER("", "IDENTIFIER"),

    // 注释
    COMMENT("", "COMMENT"),

    // 运算符
    //      比较云算法
    OPERATOR_EQEQ("==", "OPERATOR_EQEQ"),
    OPERATOR_NE("!=", "OPERATOR_NE"),
    OPERATOR_GTEQ(">=", "OPERATOR_GTEQ"),
    OPERATOR_LTEQ("<=", "OPERATOR_LTEQ"),

    OPERATOR_GT("<", "OPERATOR_GT"),
    OPERATOR_LT(">", "OPERATOR_LT"),
    OPERATOR_LTGT("<>", "OPERATOR_LTGT"),
    //      算术运算符
    OPERATOR_PLUS("+", "OPERATOR_PLUS"),
    OPERATOR_SUBSTRACT("-", "OPERATOR_SUBSTRACT"),
    OPERATOR_START("*", "OPERATOR_START"),
    OPERATOR_POWER("**", "OPERATOR_POWER"),
    OPERATOR_DIVIDE("/", "OPERATOR_DIVIDE"),
    OPERATOR_FLOOR("//", "OPERATOR_FLOOR"),
    OPERATOR_MOD("%", "OPERATOR_MOD"),
    //      位运算符,
    OPERATOR_BITWISE_XOR("^", "OPERATOR_XOR"),
    OPERATOR_BITWISE_OR("|", "OPERATOR_BITWISE_OR"),
    OPERATOR_BITWISE_AND("&", "OPERATOR_BITWISE_AND"),
    OPERATOR_BITWISE_NOT("!", "OPERATOR_BITWISE_NOT"),
    OPERATOR_BITWISE_NEGATION("~", "OPERATOR_BITWISE_NEGATION"),
    OPERATOR_BITWISE_LMOV("<<", "OPERATOR_BITWISE_LMOV"),
    OPERATOR_BITWISE_RMOV(">>", "OPERATOR_BITWISE_RMOV"),

    //      赋值运算符
    OPERATOR_EQ("=", "OPERATOR_EQ"),
    OPERATOR_PLUS_EQ("+=", "OPERATOR_PLUS_EQ"),
    OPERATOR_SUBSTRACT_EQ("-=", "OPERATOR_SUBSTRACT_EQ"),
    OPERATOR_START_EQ("*=", "OPERATOR_START_EQ"),
    OPERATOR_POWER_EQ("**=", "OPERATOR_POWER_EQ"),
    OPERATOR_DIVIDE_EQ("/=", "OPERATOR_DIVIDE_EQ"),
    OPERATOR_FLOOR_EQ("//=", "OPERATOR_FLOOR_EQ"),
    OPERATOR_MOD_EQ("%=", "OPERATOR_MOD_EQ"),

    // 界符 PARENTHESIS parenthesis
    DELIMITER_LPARENTHESIS("(", "DELIMITER_LPARENTHESIS"),
    DELIMITER_RPARENTHESIS(")", "DELIMITER_RPARENTHESIS"),
    DELIMITER_LBRACE("{", "DELIMITER_LBRACE"),
    DELIMITER_RBRACE("}", "DELIMITER_RBRACE"),
    DELIMITER_LBRACKT("[", "DELIMITER_LBRACKT"),
    DELIMITER_RBRACKT("]", "DELIMITER_RBRACKT"),
    DELIMITER_COMMA(",", "DELIMITER_COMMA"),
    DELIMITER_DOT(".", "DELIMITER_DOT"),
    DELIMITER_COLON(":", "DELIMITER_COLON"),
    DELIMITER_AT("@", "DELIMITER_AT"),
    DELIMITER_SEMICOLON(";", "DELIMITER_SEMICOLON"),

    DELIMITER_WHITE_SPACE(" ", "DELIMITER_WHITE_SPACE"),
    DELIMITER_LINE_TERMINATOR("", "DELIMITER_LINE_TERMINATOR"),


    // 错误情况
    INVALID_TOKEN("", "INVALID_TOKEN");

    int kind_id;
    String stringVal;
    String name;

    TokenKind(String stringVal, String name) {
        this.stringVal = stringVal;
        this.name = name;
    }

    TokenKind(int kind_id) {
        this.kind_id = kind_id;
        this.stringVal = "";
        this.name = "";
    }

    TokenKind(String stringVal) {
        this.kind_id = -1;
        this.stringVal = stringVal;
        this.name = stringVal;
    }

    TokenKind(int kind_id, String stringVal, String name) {
        this.kind_id = kind_id;
        this.stringVal = stringVal;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getKind_id() {
        return kind_id;
    }

    public void setKind_id(int kind_id) {
        this.kind_id = kind_id;
    }

    public String getStringVal() {
        return stringVal;
    }

    public void setStringVal(String stringVal) {
        this.stringVal = stringVal;
    }
}
